package chpt_05_01_adaptor;

/**
 * @author Ping
 * @date 2023/3/30 9:17
 **/

import org.springframework.stereotype.Component;

/**
 * Adaptor role in Adapter pattern by Inheritance.
 */
@Component("moreSatetyAdaptorStatic")
public class MoreSafetyAdaptor extends MD5Encoder
         implements MoreSafetyEncoder {
    @Override
    public String encodeInRound(String text, int round)
             throws Throwable {
        String ret = text ;
        for (int i=0; i<round; i++ ){

            ret = this.encode(ret) ;
        }
        return ret;
    }

    @Override
    public String encodeBySalt(String text, String salt)
            throws Throwable {
        return this.encode(text + salt);
    }
}
